﻿using System.Globalization;

namespace MyFifthCsharp
{/// <summary>
/// Find the biggest prime number
/// </summary>
    internal class Program
    {
        static void Main(string[] args)
        {
            //给出范围
            Console.Write("请输入一个数:");
            int input = int.Parse(Console.ReadLine());
            Console.Write(input);
            
            
            //开始循环
            int j = 2;
            DateTime Beforerunning = DateTime.Now;
            for (; input>0; input--)//从最大的数开始减减，节省时间
            {
                for (j = 2; j <=input; j++)
                {
                    if (input % j == 0)
                        break;
                }
                if (input == j)
                {
                    Console.WriteLine($"以内最大的质数是{input}");
                    break;
                }
               

            }    
            

                //计算运行时间
                DateTime Afterrunning = DateTime.Now;
                var Runningtime = Afterrunning.Subtract(Beforerunning);
                Console.Write($"运行时间为：{Runningtime}");

        } 
        
    }
}